<div [formGroup]="form" class="age-input">
    <mat-form-field>
        <input matInput [matDatepicker]="picker" formControlName="birthday" placeholder="出生日期">
        <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
        <mat-error>日期不正确</mat-error>
        <mat-datepicker #picker></mat-datepicker>
    </mat-form-field>
    <ng-container formGroupName="age">
        <div class="age-num">
            <mat-form-field>
                <input matInput type="number" placeholder="年龄" formControlName="ageNum">
            </mat-form-field>
        </div>
        <div class="age-btn">
            <mat-button-toggle-group formControlName="ageUnit" [(ngModel)]="selectedUnit">
                <mat-button-toggle *ngFor="let unit of ageUnits" [value]="unit?.value">
                    {{ unit?.label }}
                </mat-button-toggle>
            </mat-button-toggle-group>
        </div>
        <mat-error class="mat-body-2" *ngIf="form.get('age')?.hasError('ageInvalid')">年龄或单位不正确</mat-error>
    </ng-container>
</div>